<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column type="index" width="50"></el-table-column>
      <!-- <el-table-column
          prop="comId"
          label="ID"
          sortable
          column-key="date">
      </el-table-column> -->
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="sex" label="性别"></el-table-column>
      <el-table-column prop="phone" label="手机号"></el-table-column>
      <el-table-column prop="email" label="邮箱"></el-table-column>
      <el-table-column prop="phone" label="手机号"></el-table-column>
      <el-table-column prop="post" label="岗位"></el-table-column>

      <el-table-column prop="tag" label="标签" filter-placement="bottom-end">
        <template slot-scope="scope">
          <div v-if="scope.row.status === 0">
            <el-tag>未处理</el-tag>
          </div>
          <div v-else-if="scope.row.status === 1">
            <el-tag type="success">已同意</el-tag>
          </div>
          <div v-else>
            <el-tag type="danger">已拒绝</el-tag>
          </div>
        </template>
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="agreeClick(scope.row)">
            同意
          </el-button>

          <el-button type="text" size="small" @click="refuseClick(scope.row)">
            拒绝
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      background
      layout="prev, pager, next"
      :current-page="currentPage"
      :page-size="pageSize"
      :total="total"
      @current-change="page"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  name: "Delivery",
  data() {
    return {
      tableData: [],
      currentPage: 1, // 当前页
      total: 0, // 总页数
      pageSize: 5, // 一页有多少内容
    };
  },
  created() {
    this.page(1);
  },
  methods: {
    page(currentPage) {
      const _this = this;
      const id = _this.$store.getters.getCompany.id;
      _this.$axios
        .get("/allStuDelivery/" + id + "?currentPage=" + currentPage)
        .then((res) => {
          // console.log(res);
          _this.tableData = res.data.data.records;
          _this.currentPage = res.data.data.current;
          _this.total = res.data.data.total;
          _this.pageSize = res.data.data.size;
        });
    },
    filterTag(value, row) {
      return row.status === value;
    },
    agreeClick(e) {
      this.$axios.get("/agreeDelivery/" + e.id).then((res) => {
        console.log(res);
        location.reload();
      });
    },
    refuseClick(e) {
      this.$axios.get("/refuseDelivery/" + e.id).then((res) => {
        console.log(res);
        location.reload();
      });
    },
  },
};
</script>

<style scoped>
</style>
